using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Decisions.HL7.Message;
using DecisionsFramework;

namespace Decisions.HL7.Message
{
    public class ConsentTypeAttribute:RuleAttribute
    {
        private Dictionary<HL7Version, string[]> validVersionCodes = new Dictionary<HL7Version, string[]>();
        private Dictionary<HL7Version, string[]> validVersionDescriptions = new Dictionary<HL7Version, string[]>();
        private Dictionary<HL7Version, HL7TableType> tableVersionTypes = new Dictionary<HL7Version, HL7TableType>();

        public ConsentTypeAttribute()
        {
            // init the values for table version types
						tableVersionTypes[HL7Version.v25] = HL7TableType.User;
						tableVersionTypes[HL7Version.v251] = HL7TableType.User;
						tableVersionTypes[HL7Version.v26] = HL7TableType.User;
						tableVersionTypes[HL7Version.v27] = HL7TableType.User;
			
            
			// init the values for version codes
						validVersionCodes[HL7Version.v25] = new string[]{"001","002","003","004","005","006","007","008","009","010","011","012","013","014","015","016","017","018","019","020","021","022","023","024","025","026","027","028","029","030","031","032","033","034","035","036","037","038","039","040","041","042","043","044","045","046","047","048","049","050","051","052","053","054","055","056","057","058","059","060","061","062","063","064","065","066","067","068","069","070","071","072","073","074","075","076","077","078","079","080","081","082","083","084","085","086","087","088","089","090","091","092","093","094","095","096","097","098","099","100","101","102","103","104","105","106","107","108","109","110","111","112","113","114","115","116","117","118","119","120","121","122","123","124","125","126","127","128","129","130","131","132","133","134","135","136","1137"};
						validVersionCodes[HL7Version.v251] = new string[]{"001","002","003","004","005","006","007","008","009","010","011","012","013","014","015","016","017","018","019","020","021","022","023","024","025","026","027","028","029","030","031","032","033","034","035","036","037","038","039","040","041","042","043","044","045","046","047","048","049","050","051","052","053","054","055","056","057","058","059","060","061","062","063","064","065","066","067","068","069","070","071","072","073","074","075","076","077","078","079","080","081","082","083","084","085","086","087","088","089","090","091","092","093","094","095","096","097","098","099","100","101","102","103","104","105","106","107","108","109","110","111","112","113","114","115","116","117","118","119","120","121","122","123","124","125","126","127","128","129","130","131","132","133","134","135","136","1137"};
						validVersionCodes[HL7Version.v26] = new string[]{"001","002","003","004","005","006","007","008","009","010","011","012","013","014","015","016","017","018","019","020","021","022","023","024","025","026","027","028","029","030","031","032","033","034","035","036","037","038","039","040","041","042","043","044","045","046","047","048","049","050","051","052","053","054","055","056","057","058","059","060","061","062","063","064","065","066","067","068","069","070","071","072","073","074","075","076","077","078","079","080","081","082","083","084","085","086","087","088","089","090","091","092","093","094","095","096","097","098","099","100","101","102","103","104","105","106","107","108","109","110","111","112","113","114","115","116","117","118","119","120","121","122","123","124","125","126","127","128","129","130","131","132","133","134","135","136","1137"};
						validVersionCodes[HL7Version.v27] = new string[]{"001","002","003","004","005","006","007","008","009","010","011","012","013","014","015","016","017","018","019","020","021","022","023","024","025","026","027","028","029","030","031","032","033","034","035","036","037","038","039","040","041","042","043","044","045","046","047","048","049","050","051","052","053","054","055","056","057","058","059","060","061","062","063","064","065","066","067","068","069","070","071","072","073","074","075","076","077","078","079","080","081","082","083","084","085","086","087","088","089","090","091","092","093","094","095","096","097","098","099","100","101","102","103","104","105","106","107","108","109","110","111","112","113","114","115","116","117","118","119","120","121","122","123","124","125","126","127","128","129","130","131","132","133","134","135","136","1137"};
			
			// init the values for version descriptions
						validVersionDescriptions[HL7Version.v25] = new string[]{"Release of Information/MR / Authorization to Disclosure Protected Health Information","Medical Procedure (invasive)","Acknowledge Receipt of Privacy Notice","Abortion","Abortion/Laminaria","Accutane - Information","Accutane - Woman","Advanced Beneficiary Notice","AFP (Alpha Fetoprotein) Screening","Amniocentesis (consent & refusal)","Anatomical Gift (organ donation)","Anesthesia - Complications","Anesthesia - Questionnaire","Angiogram","Angioplasty","Anticancer Drugs","Antipsychotic Medications","Arthrogram","Autopsy","AZT Therapy","Biliary Drainage","Biliary Stone Extraction","Biopsy","Bleeding Time Test","Bronchogram","Cardiac Catheterization","Coronary Angiography","\"\"      \"\" w/o Surgery Capability","Cataract Op/Implant of FDA Aprvd Lens","Cataract Op/Implant of Investigational Lens","Cataract Surgery","Cholera Immunization","Cholesterol Screening","Circumcision - Newborn","Colonoscopy","Contact Lenses","CT Scan - Cervical & Lumbar","CT Scan w/ IV Contrast Media into Vein","CVS (Chorionic Villus) Sampling","Cystospy","Disclosure of Protected Health Information to Family/Friends","D & C and Conization","Dacryocystogram","Diagnostic Isotope","Drainage of an Abscess","Drug Screening","Electronic Monitoring of Labor - Refusal","Endometrial Biopsy","Endoscopy/Sclerosis of Esophageal Varices","ERCP","Exposure to reportable Communicable Disease","External Version","Fluorescein Angioscopy","Hepatitis B - Consent/Declination","Herniogram","HIV Test - Consent Refusal","HIV Test - Disclosure","HIV Test - Prenatal","Home IV Treatment Program","Home Parenteral Treatment Program","Hysterectomy","Hysterosalpingogram","Injection Slip/ Consent","Intrauterine Device","Intrauterine Device/Sterilization","Intravascular Infusion of Streptokinase/Urokinase","Intravenous Cholangiogram","Intravenous Digital Angiography","Iodine Administration","ISG","IVP","Laser Photocoagulation","Laser treatment","Lithium Carbonate","Liver Biopsy","Lumbar Puncture","Lymphangiogram","MAO Inhibitors","Med, Psych, and/or Drug/Alcohol","Medical Treatment - Refusal","Morning-after Pill","MRI - Adult","MRI - Pediatric","Myelogram","Needle Biopsy","Needle Biopsy of Lung","Newborn Treatment and Release","Norplant Subdermal Birth Control Implant","Operations, Anesthesia, Transfusions","Oral Contraceptives","Organ Donation","Patient Permits, Consents","Patient Treatment Permit, Release & Admission","Penile Injections","Percutaneous Nephrostomy","Percutaneous Transhepatic Cholangiogram","Photographs","Photographs - Employee","Photographs - Medical Research","Photographs - news Media","Psychiatric Admission - Next of Kin","Psychiatric Information During Hospital Stay","Public Release of Information","Radiologic Procedure","Refusal of Treatment","Release of Body","Release of Limb","Rh Immune Globulin","Rights of Medical Research Participants","Request to Restrict Access/Disclosure to Medical Record/Protected Health Information","Request for Remain Anonymous","Seat Belt Exemption","Sialogram","Sigmoidoscopy","Sterilization - Anesthesia & Medical Services","Sterilization -Federally Funded","Sterilization - Female","Sterilization - Laparoscopy/Pomeroy","Sterilization - Non-Federally Funded","Sterilization - Secondary","Tranquilizers","Transfer - Acknowledgement","Transfer - Authorization","Transfer Certification - Physician","Transfer/Discharge Request","Transfer for Non-Medical Reasons","Transfer - Interfaculty Neonatal","Transfer Refusal","Transfer Refusal of Further Treatment","Treadmill & EKG","Treadmill, Thallium-201","Typhoid","Use of Investigational Device","Use of Investigational Drug","Venogram","Videotape","Voiding Cystogram"};
						validVersionDescriptions[HL7Version.v251] = new string[]{"Release of Information/MR / Authorization to Disclosure Protected Health Information","Medical Procedure (invasive)","Acknowledge Receipt of Privacy Notice","Abortion","Abortion/Laminaria","Accutane - Information","Accutane - Woman","Advanced Beneficiary Notice","AFP (Alpha Fetoprotein) Screening","Amniocentesis (consent & refusal)","Anatomical Gift (organ donation)","Anesthesia - Complications","Anesthesia - Questionnaire","Angiogram","Angioplasty","Anticancer Drugs","Antipsychotic Medications","Arthrogram","Autopsy","AZT Therapy","Biliary Drainage","Biliary Stone Extraction","Biopsy","Bleeding Time Test","Bronchogram","Cardiac Catheterization","Coronary Angiography","\"\"      \"\" w/o Surgery Capability","Cataract Op/Implant of FDA Aprvd Lens","Cataract Op/Implant of Investigational Lens","Cataract Surgery","Cholera Immunization","Cholesterol Screening","Circumcision - Newborn","Colonoscopy","Contact Lenses","CT Scan - Cervical & Lumbar","CT Scan w/ IV Contrast Media into Vein","CVS (Chorionic Villus) Sampling","Cystospy","Disclosure of Protected Health Information to Family/Friends","D & C and Conization","Dacryocystogram","Diagnostic Isotope","Drainage of an Abscess","Drug Screening","Electronic Monitoring of Labor - Refusal","Endometrial Biopsy","Endoscopy/Sclerosis of Esophageal Varices","ERCP","Exposure to reportable Communicable Disease","External Version","Fluorescein Angioscopy","Hepatitis B - Consent/Declination","Herniogram","HIV Test - Consent Refusal","HIV Test - Disclosure","HIV Test - Prenatal","Home IV Treatment Program","Home Parenteral Treatment Program","Hysterectomy","Hysterosalpingogram","Injection Slip/ Consent","Intrauterine Device","Intrauterine Device/Sterilization","Intravascular Infusion of Streptokinase/Urokinase","Intravenous Cholangiogram","Intravenous Digital Angiography","Iodine Administration","ISG","IVP","Laser Photocoagulation","Laser treatment","Lithium Carbonate","Liver Biopsy","Lumbar Puncture","Lymphangiogram","MAO Inhibitors","Med, Psych, and/or Drug/Alcohol","Medical Treatment - Refusal","Morning-after Pill","MRI - Adult","MRI - Pediatric","Myelogram","Needle Biopsy","Needle Biopsy of Lung","Newborn Treatment and Release","Norplant Subdermal Birth Control Implant","Operations, Anesthesia, Transfusions","Oral Contraceptives","Organ Donation","Patient Permits, Consents","Patient Treatment Permit, Release & Admission","Penile Injections","Percutaneous Nephrostomy","Percutaneous Transhepatic Cholangiogram","Photographs","Photographs - Employee","Photographs - Medical Research","Photographs - news Media","Psychiatric Admission - Next of Kin","Psychiatric Information During Hospital Stay","Public Release of Information","Radiologic Procedure","Refusal of Treatment","Release of Body","Release of Limb","Rh Immune Globulin","Rights of Medical Research Participants","Request to Restrict Access/Disclosure to Medical Record/Protected Health Information","Request for Remain Anonymous","Seat Belt Exemption","Sialogram","Sigmoidoscopy","Sterilization - Anesthesia & Medical Services","Sterilization -Federally Funded","Sterilization - Female","Sterilization - Laparoscopy/Pomeroy","Sterilization - Non-Federally Funded","Sterilization - Secondary","Tranquilizers","Transfer - Acknowledgement","Transfer - Authorization","Transfer Certification - Physician","Transfer/Discharge Request","Transfer for Non-Medical Reasons","Transfer - Interfaculty Neonatal","Transfer Refusal","Transfer Refusal of Further Treatment","Treadmill & EKG","Treadmill, Thallium-201","Typhoid","Use of Investigational Device","Use of Investigational Drug","Venogram","Videotape","Voiding Cystogram"};
						validVersionDescriptions[HL7Version.v26] = new string[]{"Release of Information/MR / Authorization to Disclosure Protected Health Information","Medical Procedure (invasive)","Acknowledge Receipt of Privacy Notice","Abortion","Abortion/Laminaria","Accutane - Information","Accutane - Woman","Advanced Beneficiary Notice","AFP (Alpha Fetoprotein) Screening","Amniocentesis (consent & refusal)","Anatomical Gift (organ donation)","Anesthesia - Complications","Anesthesia - Questionnaire","Angiogram","Angioplasty","Anticancer Drugs","Antipsychotic Medications","Arthrogram","Autopsy","AZT Therapy","Biliary Drainage","Biliary Stone Extraction","Biopsy","Bleeding Time Test","Bronchogram","Cardiac Catheterization","Coronary Angiography","\"\"      \"\" w/o Surgery Capability","Cataract Op/Implant of FDA Aprvd Lens","Cataract Op/Implant of Investigational Lens","Cataract Surgery","Cholera Immunization","Cholesterol Screening","Circumcision - Newborn","Colonoscopy","Contact Lenses","CT Scan - Cervical & Lumbar","CT Scan w/ IV Contrast Media into Vein","CVS (Chorionic Villus) Sampling","Cystospy","Disclosure of Protected Health Information to Family/Friends","D & C and Conization","Dacryocystogram","Diagnostic Isotope","Drainage of an Abscess","Drug Screening","Electronic Monitoring of Labor - Refusal","Endometrial Biopsy","Endoscopy/Sclerosis of Esophageal Varices","ERCP","Exposure to reportable Communicable Disease","External Version","Fluorescein Angioscopy","Hepatitis B - Consent/Declination","Herniogram","HIV Test - Consent Refusal","HIV Test - Disclosure","HIV Test - Prenatal","Home IV Treatment Program","Home Parenteral Treatment Program","Hysterectomy","Hysterosalpingogram","Injection Slip/ Consent","Intrauterine Device","Intrauterine Device/Sterilization","Intravascular Infusion of Streptokinase/Urokinase","Intravenous Cholangiogram","Intravenous Digital Angiography","Iodine Administration","ISG","IVP","Laser Photocoagulation","Laser treatment","Lithium Carbonate","Liver Biopsy","Lumbar Puncture","Lymphangiogram","MAO Inhibitors","Med, Psych, and/or Drug/Alcohol","Medical Treatment - Refusal","Morning-after Pill","MRI - Adult","MRI - Pediatric","Myelogram","Needle Biopsy","Needle Biopsy of Lung","Newborn Treatment and Release","Norplant Subdermal Birth Control Implant","Operations, Anesthesia, Transfusions","Oral Contraceptives","Organ Donation","Patient Permits, Consents","Patient Treatment Permit, Release & Admission","Penile Injections","Percutaneous Nephrostomy","Percutaneous Transhepatic Cholangiogram","Photographs","Photographs - Employee","Photographs - Medical Research","Photographs - news Media","Psychiatric Admission - Next of Kin","Psychiatric Information During Hospital Stay","Public Release of Information","Radiologic Procedure","Refusal of Treatment","Release of Body","Release of Limb","Rh Immune Globulin","Rights of Medical Research Participants","Request to Restrict Access/Disclosure to Medical Record/Protected Health Information","Request for Remain Anonymous","Seat Belt Exemption","Sialogram","Sigmoidoscopy","Sterilization - Anesthesia & Medical Services","Sterilization -Federally Funded","Sterilization - Female","Sterilization - Laparoscopy/Pomeroy","Sterilization - Non-Federally Funded","Sterilization - Secondary","Tranquilizers","Transfer - Acknowledgement","Transfer - Authorization","Transfer Certification - Physician","Transfer/Discharge Request","Transfer for Non-Medical Reasons","Transfer - Interfaculty Neonatal","Transfer Refusal","Transfer Refusal of Further Treatment","Treadmill & EKG","Treadmill, Thallium-201","Typhoid","Use of Investigational Device","Use of Investigational Drug","Venogram","Videotape","Voiding Cystogram"};
						validVersionDescriptions[HL7Version.v27] = new string[]{"Release of Information/MR / Authorization to Disclosure Protected Health Information","Medical Procedure (invasive)","Acknowledge Receipt of Privacy Notice","Abortion","Abortion/Laminaria","Accutane - Information","Accutane - Woman","Advanced Beneficiary Notice","AFP (Alpha Fetoprotein) Screening","Amniocentesis (consent & refusal)","Anatomical Gift (organ donation)","Anesthesia - Complications","Anesthesia - Questionnaire","Angiogram","Angioplasty","Anticancer Drugs","Antipsychotic Medications","Arthrogram","Autopsy","AZT Therapy","Biliary Drainage","Biliary Stone Extraction","Biopsy","Bleeding Time Test","Bronchogram","Cardiac Catheterization","Coronary Angiography","\"\"      \"\" w/o Surgery Capability","Cataract Op/Implant of FDA Aprvd Lens","Cataract Op/Implant of Investigational Lens","Cataract Surgery","Cholera Immunization","Cholesterol Screening","Circumcision - Newborn","Colonoscopy","Contact Lenses","CT Scan - Cervical & Lumbar","CT Scan w/ IV Contrast Media into Vein","CVS (Chorionic Villus) Sampling","Cystospy","Disclosure of Protected Health Information to Family/Friends","D & C and Conization","Dacryocystogram","Diagnostic Isotope","Drainage of an Abscess","Drug Screening","Electronic Monitoring of Labor - Refusal","Endometrial Biopsy","Endoscopy/Sclerosis of Esophageal Varices","ERCP","Exposure to reportable Communicable Disease","External Version","Fluorescein Angioscopy","Hepatitis B - Consent/Declination","Herniogram","HIV Test - Consent Refusal","HIV Test - Disclosure","HIV Test - Prenatal","Home IV Treatment Program","Home Parenteral Treatment Program","Hysterectomy","Hysterosalpingogram","Injection Slip/ Consent","Intrauterine Device","Intrauterine Device/Sterilization","Intravascular Infusion of Streptokinase/Urokinase","Intravenous Cholangiogram","Intravenous Digital Angiography","Iodine Administration","ISG","IVP","Laser Photocoagulation","Laser treatment","Lithium Carbonate","Liver Biopsy","Lumbar Puncture","Lymphangiogram","MAO Inhibitors","Med, Psych, and/or Drug/Alcohol","Medical Treatment - Refusal","Morning-after Pill","MRI - Adult","MRI - Pediatric","Myelogram","Needle Biopsy","Needle Biopsy of Lung","Newborn Treatment and Release","Norplant Subdermal Birth Control Implant","Operations, Anesthesia, Transfusions","Oral Contraceptives","Organ Donation","Patient Permits, Consents","Patient Treatment Permit, Release & Admission","Penile Injections","Percutaneous Nephrostomy","Percutaneous Transhepatic Cholangiogram","Photographs","Photographs - Employee","Photographs - Medical Research","Photographs - news Media","Psychiatric Admission - Next of Kin","Psychiatric Information During Hospital Stay","Public Release of Information","Radiologic Procedure","Refusal of Treatment","Release of Body","Release of Limb","Rh Immune Globulin","Rights of Medical Research Participants","Request to Restrict Access/Disclosure to Medical Record/Protected Health Information","Request for Remain Anonymous","Seat Belt Exemption","Sialogram","Sigmoidoscopy","Sterilization - Anesthesia & Medical Services","Sterilization -Federally Funded","Sterilization - Female","Sterilization - Laparoscopy/Pomeroy","Sterilization - Non-Federally Funded","Sterilization - Secondary","Tranquilizers","Transfer - Acknowledgement","Transfer - Authorization","Transfer Certification - Physician","Transfer/Discharge Request","Transfer for Non-Medical Reasons","Transfer - Interfaculty Neonatal","Transfer Refusal","Transfer Refusal of Further Treatment","Treadmill & EKG","Treadmill, Thallium-201","Typhoid","Use of Investigational Device","Use of Investigational Drug","Venogram","Videotape","Voiding Cystogram"};
			            

        }

        
        public override ValidationIssue[] RunRule(string name, object owningObject, object value)
        {
            //todo: check if the value is valid in the current version
            //if the value is not valid in the current version, add it as a validation issue


            return new ValidationIssue[0];
        }
    }
}
